/**
 */
package org.autosar.schema.r4.impl;

import org.autosar.schema.r4.EVENTGROUPTYPE;
import org.autosar.schema.r4.EVENTSTYPE;
import org.autosar.schema.r4.R4Package;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>EVENTGROUPTYPE</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.autosar.schema.r4.impl.EVENTGROUPTYPEImpl#getSHORTNAME <em>SHORTNAME</em>}</li>
 *   <li>{@link org.autosar.schema.r4.impl.EVENTGROUPTYPEImpl#getEVENTGROUPID <em>EVENTGROUPID</em>}</li>
 *   <li>{@link org.autosar.schema.r4.impl.EVENTGROUPTYPEImpl#getEVENTS <em>EVENTS</em>}</li>
 * </ul>
 *
 * @generated
 */
public class EVENTGROUPTYPEImpl extends MinimalEObjectImpl.Container implements EVENTGROUPTYPE {
	/**
	 * The default value of the '{@link #getSHORTNAME() <em>SHORTNAME</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSHORTNAME()
	 * @generated
	 * @ordered
	 */
	protected static final String SHORTNAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getSHORTNAME() <em>SHORTNAME</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSHORTNAME()
	 * @generated
	 * @ordered
	 */
	protected String sHORTNAME = SHORTNAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getEVENTGROUPID() <em>EVENTGROUPID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEVENTGROUPID()
	 * @generated
	 * @ordered
	 */
	protected static final int EVENTGROUPID_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getEVENTGROUPID() <em>EVENTGROUPID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEVENTGROUPID()
	 * @generated
	 * @ordered
	 */
	protected int eVENTGROUPID = EVENTGROUPID_EDEFAULT;

	/**
	 * This is true if the EVENTGROUPID attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean eVENTGROUPIDESet;

	/**
	 * The cached value of the '{@link #getEVENTS() <em>EVENTS</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEVENTS()
	 * @generated
	 * @ordered
	 */
	protected EVENTSTYPE eVENTS;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EVENTGROUPTYPEImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return R4Package.Literals.EVENTGROUPTYPE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getSHORTNAME() {
		return sHORTNAME;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSHORTNAME(String newSHORTNAME) {
		String oldSHORTNAME = sHORTNAME;
		sHORTNAME = newSHORTNAME;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, R4Package.EVENTGROUPTYPE__SHORTNAME, oldSHORTNAME, sHORTNAME));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getEVENTGROUPID() {
		return eVENTGROUPID;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEVENTGROUPID(int newEVENTGROUPID) {
		int oldEVENTGROUPID = eVENTGROUPID;
		eVENTGROUPID = newEVENTGROUPID;
		boolean oldEVENTGROUPIDESet = eVENTGROUPIDESet;
		eVENTGROUPIDESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, R4Package.EVENTGROUPTYPE__EVENTGROUPID, oldEVENTGROUPID, eVENTGROUPID, !oldEVENTGROUPIDESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetEVENTGROUPID() {
		int oldEVENTGROUPID = eVENTGROUPID;
		boolean oldEVENTGROUPIDESet = eVENTGROUPIDESet;
		eVENTGROUPID = EVENTGROUPID_EDEFAULT;
		eVENTGROUPIDESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, R4Package.EVENTGROUPTYPE__EVENTGROUPID, oldEVENTGROUPID, EVENTGROUPID_EDEFAULT, oldEVENTGROUPIDESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetEVENTGROUPID() {
		return eVENTGROUPIDESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EVENTSTYPE getEVENTS() {
		return eVENTS;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetEVENTS(EVENTSTYPE newEVENTS, NotificationChain msgs) {
		EVENTSTYPE oldEVENTS = eVENTS;
		eVENTS = newEVENTS;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, R4Package.EVENTGROUPTYPE__EVENTS, oldEVENTS, newEVENTS);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEVENTS(EVENTSTYPE newEVENTS) {
		if (newEVENTS != eVENTS) {
			NotificationChain msgs = null;
			if (eVENTS != null)
				msgs = ((InternalEObject)eVENTS).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - R4Package.EVENTGROUPTYPE__EVENTS, null, msgs);
			if (newEVENTS != null)
				msgs = ((InternalEObject)newEVENTS).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - R4Package.EVENTGROUPTYPE__EVENTS, null, msgs);
			msgs = basicSetEVENTS(newEVENTS, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, R4Package.EVENTGROUPTYPE__EVENTS, newEVENTS, newEVENTS));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case R4Package.EVENTGROUPTYPE__EVENTS:
				return basicSetEVENTS(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case R4Package.EVENTGROUPTYPE__SHORTNAME:
				return getSHORTNAME();
			case R4Package.EVENTGROUPTYPE__EVENTGROUPID:
				return getEVENTGROUPID();
			case R4Package.EVENTGROUPTYPE__EVENTS:
				return getEVENTS();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case R4Package.EVENTGROUPTYPE__SHORTNAME:
				setSHORTNAME((String)newValue);
				return;
			case R4Package.EVENTGROUPTYPE__EVENTGROUPID:
				setEVENTGROUPID((Integer)newValue);
				return;
			case R4Package.EVENTGROUPTYPE__EVENTS:
				setEVENTS((EVENTSTYPE)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case R4Package.EVENTGROUPTYPE__SHORTNAME:
				setSHORTNAME(SHORTNAME_EDEFAULT);
				return;
			case R4Package.EVENTGROUPTYPE__EVENTGROUPID:
				unsetEVENTGROUPID();
				return;
			case R4Package.EVENTGROUPTYPE__EVENTS:
				setEVENTS((EVENTSTYPE)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case R4Package.EVENTGROUPTYPE__SHORTNAME:
				return SHORTNAME_EDEFAULT == null ? sHORTNAME != null : !SHORTNAME_EDEFAULT.equals(sHORTNAME);
			case R4Package.EVENTGROUPTYPE__EVENTGROUPID:
				return isSetEVENTGROUPID();
			case R4Package.EVENTGROUPTYPE__EVENTS:
				return eVENTS != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuilder result = new StringBuilder(super.toString());
		result.append(" (sHORTNAME: ");
		result.append(sHORTNAME);
		result.append(", eVENTGROUPID: ");
		if (eVENTGROUPIDESet) result.append(eVENTGROUPID); else result.append("<unset>");
		result.append(')');
		return result.toString();
	}

} //EVENTGROUPTYPEImpl
